 /**  
 * @fileOverview "initEditor"
 * @author tan
 * @version 1.0  
 */  
 /**  
 * @author tan  
 * @constructor initEditor
 * @description "initEditor"
 * @date 2010-11-17
 * @since version 1.0 
 */ 
var initEditor=function(){
	 
	

	/**
	 * @description 加载编辑器
	 * @moed:模式,streamline:简单,complex：复杂
	 */
	this.lazyInitEditor=function(textareaId,moed){
		setTimeout(function() 
				{  
			 		initXHEditor(textareaId,moed);
			 	},0);  
	}
	
	
	
	 this.initXHEditor=function(textareaId,moed){
		 	var tools='subscript,Fullscreen,|,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,|,FontColor,BackColor,|,Removeformat,Align,List,Outdent,Indent,Link,Unlink,|,Img,Flash,Source';
		 	if(moed=='streamline'){
		 		tools='Bold,Italic,Underline,Strikethrough,|,FontColor,BackColor,|,Link,|,Img,Source';
		 	}
			$(textareaId).xheditor({
				skin:'o2007blue',
				tools:tools,
				upImgUrl:"uploadFile!uploadImage.action?immediate=1&flag=editor",
				upImgExt:"jpg,jpeg,gif,png",
				upFlashUrl:"uploadFile!uploadFlash.action?flag=editor",
				upFlashExt:"swf",
				upLinkUrl:'uploadFile!uploadAttr.action?flag=editor',
				upLinkExt:"doc,docx,xls,rar,zip,txt,pdf,gif,jpg,png,bmp,swf",
				showBlocktag:true,
				html5Upload:false,
				forcePtag:false,
				formatXHTML:true,
				forcePtag:false,//强制P标签，默认为true
				onUpload:insertUpload
				});
	 }
	 
	 
	 this.insertUpload=function(res){
		 
//		 
//		 var attrText=$('#attachments').text();
//		 
//		 
//		 if(attrText.indexOf("暂无附件")!=-1){
//			 
//			 $('#attachments').html("");
//		 }
//		 
//
//		 var fileExt=res.substring(res.indexOf(".")+1);
//		 var fileTypes="doc,docx,xls,rar,zip,txt,pdf";
//		 
//		 if(fileTypes.indexOf(fileExt)!=-1){
//			 $('#attachments').append(res+"<br/>");
//			 
//		 }
		 
	 }
	 
	 
 }();
 
